<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <include file="Public:resource"/>
    <title>填写信息</title>
</head>
<body>
<div class="container">
    <include file="Public:top" title="填写个人信息"/>

    <form id="infoForm" method="post">
        <div class="row form-row" align="left" style="margin-top: 30px;">
            <div class="col-xs-4 col-md-4 col-sm-4 col-lg-4 align-to-input">
                姓名
            </div>
            <div class="col-xs-8 col-md-8 col-sm-8 col-lg-8 align-to-input">
                <input type="text" id="name" placeholder="请填写姓名">
            </div>
        </div>
        <div class="row form-row" align="left">
            <div class="col-xs-4 col-md-4 col-sm-4 col-lg-4 align-to-input">
                手机
            </div>
            <div class="col-xs-8 col-md-8 col-sm-8 col-lg-8 align-to-input">
                <input type="text" id="phone" placeholder="请填写手机号码">
            </div>
        </div>
        <div class="row form-row" align="left">
            <div class="col-xs-4 col-md-4 col-sm-4 col-lg-4 align-to-input">
                邮箱
            </div>
            <div class="col-xs-8 col-md-8 col-sm-8 col-lg-8 align-to-input">

                <input type="text" id="email" placeholder="请填写邮箱">
            </div>
        </div>
    </form>
    <div class="row form-row" style="margin-top: 20px;">
        <div class="col-xs-12 col-md-12 col-sm-12 col-lg-12">
            <input type="button" class="btn btn-lg btn-block jss-button"
                   onclick="onSubmit() " value="提交"/>
        </div>
    </div>
</div>
<include file="Public:progress" hint="提交中..."/>
<include file="Public:message"/>

<script>
    function onSubmit() {
        if (!checkInfo('name', 'phone', 'email')) {
            return;
        }
        showProgress();
        var param = {
            name: $("#name").val(),
            phone: $("#phone").val(),
            email: $("#email").val()
        }
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: param,
            async :false,
            url: "{:U('Account/doFill')}",
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            success: function (json) {
                hideProgress();
                if (json.status == 'success') {
                    showMessage(json.msg, 2000);
                    setTimeout(function () {
                        window.location.href = "{:U('index')}";
                    }, 1000);
                } else {
                    alert(json.msg);
                }
            },
            error: function (msg) {
                hideProgress();
                alert("修改失败,请检查网络!");

            }
        });

    }
</script>
</body>
</html>